# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgbase=libtasn1
pkgname=('libtasn1' 'libtasn1-devel')
pkgver=4.13
pkgrel=1
pkgdesc="A library for Abstract Syntax Notation One (ASN.1) and Distinguish Encoding Rules (DER) manipulation"
arch=('i686' 'x86_64')
license=('GPL3' 'LGPL')
url="https://www.gnu.org/software/libtasn1/"
makedepends=('gcc' 'texinfo' 'make' 'patch')
source=(https://ftp.gnu.org/gnu/libtasn1/${pkgname}-${pkgver}.tar.gz{,.sig}
        libtasn1-3.3-msys2.patch)
sha256sums=('7e528e8c317ddd156230c4e31d082cd13e7ddeb7a54824be82632209550c8cca'
            'SKIP'
            'd6934f9cc97d01df148cf879961a96cb41e8874d31b4f89d0b80247aabbc4143')
validpgpkeys=('0424D4EE81A0E3D119C6F835EDA21E94B565716F'
              '1F42418905D8206AA754CCDC29EE58B996865171')

prepare() {
  cd ${pkgname}-${pkgver}
  patch -p1 -i $srcdir/libtasn1-3.3-msys2.patch
  autoreconf -i
}

build() {
  cd ${pkgname}-${pkgver}
  ./configure --build=${CHOST} --prefix=/usr
  make
  make DESTDIR=$srcdir/dest install
}

check() {
  cd ${pkgname}-${pkgver}
  make check
}

package_libtasn1() {
  depends=('info')
  groups=('libraries')
  install=libtasn1.install

  mkdir -p ${pkgdir}/usr/bin
  cp -f ${srcdir}/dest/usr/bin/*.dll ${pkgdir}/usr/bin/
  cp -rf ${srcdir}/dest/usr/share ${pkgdir}/usr/
}

package_libtasn1-devel() {
  pkgdesc="Libtasn1 headers and libraries"
  groups=('development')
  depends=("libtasn1=${pkgver}")

  mkdir -p ${pkgdir}/usr/bin
  cp -f ${srcdir}/dest/usr/bin/*.exe ${pkgdir}/usr/bin/
  cp -rf ${srcdir}/dest/usr/include ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/lib ${pkgdir}/usr/
}
